//
//  CartNullView.m
//  JiaoX
//
//  Created by jiaoxiu－005 on 15/1/15.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//
#define CART_NULL_TIP_SIZE  [DimensUtils getScaleX:14]
#define CART_NULL_TIP_SIZE2  [DimensUtils getScaleX:10]
#define CART_NULL_TIPS_COLOR JXColor(77, 77, 77)

#import "CartNullView.h"
@interface CartNullView()
{
    UIImageView *_cartIconImageView;
    UILabel *_cartLabel;
    UILabel *_cartLabel2;
    UIButton *_scrollButton;
}
@end
@implementation CartNullView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
        //购物车图片
        UIImage *img = [UIImage imageNamed:@"cart_icon_null"];
        _cartIconImageView = [[UIImageView alloc ]initWithImage:img];
        [_cartIconImageView setFrame:CGRectMake((155-img.size.width)/2, 0, img.size.width, img.size.height)];
        [self addSubview:_cartIconImageView];
        
        //文字1
        NSString *nullStr = @"购物车还空着呢";
        _cartLabel = [[UILabel alloc]init];
        [_cartLabel setText:nullStr];
       
        [_cartLabel setFont:[UIFont systemFontOfSize:CART_NULL_TIP_SIZE]];
        [_cartLabel setTextColor:CART_NULL_TIPS_COLOR];
        CGSize nullStrSize = [nullStr sizeWithFont:[UIFont systemFontOfSize:CART_NULL_TIP_SIZE]];
        //这儿不能写死距左边10.得算
//        [_cartLabel setFrame:CGRectMake(JXPublicInset, CGRectGetMaxY(_cartIconImageView.frame)+JXPublicInset, nullStrSize.width, nullStrSize.height)];
        //by yqy
        [_cartLabel setFrame:CGRectMake((155-nullStrSize.width)/2, CGRectGetMaxY(_cartIconImageView.frame)+JXPublicInset, nullStrSize.width, nullStrSize.height)];
        [self addSubview:_cartLabel];
        //文字2
         NSString *selectStr = @"赶紧选几件爽爽去~";
        _cartLabel2 = [[UILabel alloc]init];
        [_cartLabel2 setText:selectStr];
        [_cartLabel2 setFont:[UIFont systemFontOfSize:CART_NULL_TIP_SIZE2]];
        [_cartLabel2 setTextColor:CART_NULL_TIPS_COLOR];
        CGSize selectStrSize = [selectStr sizeWithFont:[UIFont systemFontOfSize:CART_NULL_TIP_SIZE2]];
        //这儿不能写死距左边22.得算
//        [_cartLabel2 setFrame:CGRectMake(22, CGRectGetMaxY(_cartLabel.frame)+5, selectStrSize.width, selectStrSize.height)];
        //by yqy
        [_cartLabel2 setFrame:CGRectMake((155-selectStrSize.width)/2, CGRectGetMaxY(_cartLabel.frame)+5, selectStrSize.width, selectStrSize.height)];
        
        [self addSubview:_cartLabel2];
        //去逛逛按钮
        _scrollButton =[[UIButton alloc]init];
        [_scrollButton setTitle:@"去逛逛" forState:UIControlStateNormal];
        [_scrollButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_scrollButton setContentMode:UIViewContentModeCenter];
        [_scrollButton setBackgroundImage:[UIImage resizedImage:@"btn_login_bg"] forState:UIControlStateNormal];
        [_scrollButton addTarget:self action:@selector(scroll) forControlEvents:UIControlEventTouchUpInside];
        [_scrollButton setFrame:CGRectMake(0, CGRectGetMaxY(_cartLabel2.frame)+JXPublicInset*2, 155, 37.5)];
        [self addSubview:_scrollButton];

        [self setSize:CGSizeMake(155, CGRectGetMaxY(_scrollButton.frame))];
    }
    return self;
}

/**
 *  去逛逛
 */
-(void)scroll{
    if ([self.delegate respondsToSelector:@selector(scroll)]) {
        [_delegate scroll];
    }
}

@end
